package controller;

import java.util.Comparator;

public class ComparatorContact implements Comparator<Contact> {
	
	public int compare(Contact c1, Contact c2)
	{
		int res = c1.getUsername().compareTo(c2.getUsername());
		if(res == 0)
		{
			return c1.getIpAddr().getHostAddress().compareTo(c2.getIpAddr().getHostAddress());
		}
		else
			return res;
	}
	
	public boolean equals(Contact c1, Contact c2)
	{
		return c1.getUsername().equals(c2.getUsername()) && c1.getIpAddr().getHostAddress().equals(c2.getIpAddr().getHostAddress());
	}
}
